/*
 * @Description: 页面描述：员工接口
 * @Author: Yong
 * @Date: 2021-05-14 16:11:06
 */
import request from '@/utils/request'

/**
 * @description: 获取部门负责人下拉数据
 * @author: Yong
 * @function   getEmployeeSimple
 * @param {*}  参数
 * @return {*} 
 * @date: 2021-05-14 16:24:20
 */

export function getEmployeeSimple () {
    return request({
        url: '/sys/user/simple'
    })
}

/**
 * @description: 获取员工数据
 * @author: Yong
 * @function   getEmployeeList
 * @param {*}  参数
 * @return {*} 
 * @date: 2021-05-14 16:24:20
 */

export function getEmployeeList (params) {
    return request({
        url: '/sys/user',
        params
    })
}

/**
 * @description: 删除员工接口
 * @author: Yong
 * @function   delEmployee
 * @param {*}  id
 * @return {*} 
 * @date: 2021-05-14 16:24:20
 */
export function delEmployee (id) {
    return request({
        url: `/sys/user/${id}`,
        method: 'delete'
    })
}

/**
 * @description: 新增员工接口
 * @author: Yong
 * @function   addEmployee
 * @param {*}  data
 * @return {*} 
 * @date: 2021-05-14 16:24:20
 */
export function addEmployee (data) {
    return request({
        method: 'post',
        url: '/sys/user',
        data
    })
}

/**
 * @description: 封装一个导入员工的接口
 * @author: Yong
 * @function   importEmployee
 * @param {*}  data
 * @return {*} 
 * @date: 2021-05-14 16:24:20
 */
export function importEmployee (data) {
    return request({
        url: '/sys/user/batch',
        method: 'post',
        data
    })
}

/**
 * @description: 保存员工的基本信息
 * @author: Yong
 * @function   saveUserDetailById
 * @param {*}  data
 * @return {*} 
 * @date: 2021-05-24 20:55:27
 */

export function saveUserDetailById (data) {
    return request({
        url: `/sys/user/${data.id}`,
        method: 'put',
        data
    })
}

/** *
 *  读取用户详情的基础信息
 * **/
export function getPersonalDetail (id) {
    return request({
        url: `/employees/${id}/personalInfo`
    })
}

/** *
 *  更新用户详情的基础信息
 * **/
export function updatePersonal (data) {
    return request({
        url: `/employees/${data.userId}/personalInfo`,
        method: 'put',
        data
    })
}


/** **
 * 获取用户的岗位信息
 *
 * ****/
export function getJobDetail (id) {
    return request({
        url: `/employees/${id}/jobs`
    })
}


/**
 * 保存岗位信息
 * ****/
export function updateJob (data) {
    return request({
        url: `/employees/${data.userId}/jobs`,
        method: 'put',
        data
    })
}

/** *
 * 给用户分配角色
 * ***/
export function assignRoles(data) {
    return request({
        url: '/sys/user/assignRoles',
        data,
        method: 'put'
    })
}
  